package com.itheima.day08.Zuoye.Zuoye4;

import java.util.Comparator;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

public class test {
        public static void main(String[] args) {
            Set<Person> set = new TreeSet<>(new Comparator<Person>() {
                @Override
                public int compare(Person o1, Person o2) {
                    return o1.getIdCard() - o2.getIdCard();
                }
            });
            set.add(new Person(154, "zhaoliu"));
            set.add(new Person(101, "zhangsan"));
            set.add(new Person(101, "zhangsan"));
            set.add(new Person(133, "wangwu"));
            set.add(new Person(115, "zhangsan"));
            set.add(new Person(115, "zhangsan"));
            set.add(new Person(112, "lisi"));
            Iterator<Person> it = set.iterator();
            while (it.hasNext()) {
                Person p = it.next();
                System.out.println(p.getIdCard() + " " + p.getUserName());
                System.out.println(p);
            }
        }
    }
